home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / April 96 / Re Creating New Frames in ODF < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  3.5 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Creating New Frames in ODF with Request EmbeddedFrame
  2. Sent:        4/17/96 3:54 PM
  3. Received:    4/17/96 4:11 PM
  4. From:        Henri Lamiraux, lamiraux@apple.com
  5. Reply-To:    ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. >How come I don't get a new frame with this? TempFrame turns up empty and my
  9. >parts NewFrame never gets called. Clearly something is wrong and I have no
  10. >doubt it is something rather simple, if someone could give me a hand I
  11. >would greatly appreciate it.
  12. >
  13. >void CDataAndMoviePart::NewMovieFrame( Environment *ev, CMovieFrame 
  14. >*RefFrame )
  15. >{
  16. >        FW_CRect        frameRect = RefFrame->GetBounds( ev );
  17. >        FW_CRect        contentRect(frameRect);
  18. >
  19. >        contentRect.Place( FW_kZeroPoint);
  20. >
  21. >        contentRect.top = frameRect.bottom + FW_IntToFixed(0);
  22. >        contentRect.bottom = contentRect.top + FW_IntToFixed(50);
  23. >
  24. >        ODSession       *session = GetSession(ev);
  25. >        ODFrame         *ContainingFrame = 
  26. >RefFrame->AcquireContainingFrame(ev);
  27. >        ODPart          *ContainingPart = ContainingFrame->AcquirePart(ev);
  28. >        ODFrame         *tempFrame;
  29. >
  30. >        tempFrame = ContainingPart->RequestEmbeddedFrame(
  31. >                 ev,
  32. >                 ContainingFrame,
  33. >                 RefFrame->GetODFrame(ev),
  34. >                 ::FW_NewODShape( ev, contentRect ),
  35. >                 GetODPart(ev),
  36. >                 gViewAsFrameToken,
  37. >                 session->Tokenize(ev,kDebugPresentation),
  38. >                 FALSE );
  39. >}
  40. >
  41. >Jer,
  42.  
  43. Look at my previous message on why this does work.
  44.  
  45. Just a note about reference counting. Be very careful in OpenDoc, objects 
  46. like ODShape and ODTransform, ODFrame etc.. are reference counted. So 
  47. lines like:
  48.  
  49. >        ODFrame         *ContainingFrame = 
  50. >RefFrame->AcquireContainingFrame(ev);
  51. >        ODPart          *ContainingPart = ContainingFrame->AcquirePart(ev);
  52. >        ODFrame         *tempFrame;
  53. >
  54. >        tempFrame = ContainingPart->RequestEmbeddedFrame(
  55. >                 ev,
  56. >                 ContainingFrame,
  57. >                 RefFrame->GetODFrame(ev),
  58. >                 ::FW_NewODShape( ev, contentRect ),
  59. >                 GetODPart(ev),
  60. >                 gViewAsFrameToken,
  61. >                 session->Tokenize(ev,kDebugPresentation),
  62. >                 FALSE );
  63.  
  64. should be
  65.  
  66.          FW_CAcquiredODFrame ContainingFrame =  
  67. RefFrame->AcquireContainingFrame(ev);
  68.          FW_CAcquiredODPart ContainingPart = 
  69. ContainingFrame->AcquirePart(ev);
  70.  
  71.          FW_AcquiredODShape frameShape = ::FW_NewODShape( ev, contentRect 
  72. ),
  73.          FW_CAcquiredODFrame tempFrame = 
  74. ContainingPart->RequestEmbeddedFrame(
  75.                   ev,
  76.                  ContainingFrame,
  77.                  RefFrame->GetODFrame(ev),
  78.                   frameShape,
  79.                   GetODPart(ev),
  80.                   gViewAsFrameToken,
  81.                   session->Tokenize(ev,kDebugPresentation),
  82.                   FALSE );
  83.  
  84. When calling OpenDoc or ODF methods starting with Acquire (like 
  85. AcquireContainingFrame) you should use a FW_CAcquiredODXXXX object. Same 
  86. thing when creating refcounted objects (like FW_NewODShape) Not doing 
  87. that will generate memory leaks or crashes. You should also use the 
  88. OpenDoc debug version. This version will warn you about refcounting 
  89. problems. 
  90.  
  91. .......................................................................
  92.  Henri Lamiraux                                      lamiraux@apple.com
  93.  Apple Computer, Inc.                 OpenDoc(tm) Development Framework
  94. .......................................................................
  95.  
  96.  
  97.